package com.example.base.exception;

import com.example.base.response.Result;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

@RestControllerAdvice(basePackages = "com.example.controller")
public class GlobalExceptionHandler {


    @ExceptionHandler(Exception.class)
    public Result error(HttpServletRequest request, Exception e) {
        return Result.error("系统异常");
    }

    @ExceptionHandler(CustomException.class)
    public Result customError(HttpServletRequest request, CustomException e) {
        return Result.error(e.getMessage());
    }
}
